#ifndef TREX_API
#define TREX_API extern
#endif
typedef unsigned int TRexBool;
#define TRex_True 1
#define TRex_False 0

#define TRexParseException TRexParseExceptionA
#define TRexpp TRexppA
#define TRexChar char
#define TRex TRexA
#define TRexMatch TRexMatchA
typedef struct TRex TRex;
typedef struct {
	const TRexChar *begin;
	int len;
} TRexMatch;
TREX_API TRex *trex_compile(const TRexChar *pattern,const TRexChar **error);
TREX_API void trex_free(TRex *exp);
TREX_API TRexBool trex_match(TRex* exp,const TRexChar* text);
TREX_API TRexBool trex_search(TRex* exp,const TRexChar* text, const TRexChar** out_begin, const TRexChar** out_end);
TREX_API TRexBool trex_searchrange(TRex* exp,const TRexChar* text_begin,const TRexChar* text_end,const TRexChar** out_begin, const TRexChar** out_end);
TREX_API int trex_getsubexpcount(TRex* exp);
TREX_API TRexBool trex_getsubexp(TRex* exp, int n, TRexMatch *subexp);
#include "TRexpp.h"
#undef TRexParseException
#undef TRexpp
#undef TRexChar
#undef TRex
#undef TRexMatch
#undef _TREXPP_H_

#define TRexParseException TRexParseExceptionW
#define TRexpp TRexppW
#define TRexChar unsigned short
#define TRex TRexW
#define TRexMatch TRexMatchW
typedef struct TRex TRex;
typedef struct {
	const TRexChar *begin;
	int len;
} TRexMatch;
TREX_API TRex *trex_compile(const TRexChar *pattern,const TRexChar **error);
TREX_API void trex_free(TRex *exp);
TREX_API TRexBool trex_match(TRex* exp,const TRexChar* text);
TREX_API TRexBool trex_search(TRex* exp,const TRexChar* text, const TRexChar** out_begin, const TRexChar** out_end);
TREX_API TRexBool trex_searchrange(TRex* exp,const TRexChar* text_begin,const TRexChar* text_end,const TRexChar** out_begin, const TRexChar** out_end);
TREX_API int trex_getsubexpcount(TRex* exp);
TREX_API TRexBool trex_getsubexp(TRex* exp, int n, TRexMatch *subexp);
#include "TRexpp.h"
#undef TRexParseException
#undef TRexpp
#undef TRexChar
#undef TRex
#undef TRexMatch

#define TRexChar unsigned short


#if 0
void TRexp_error()
{
     int xxx = 0;
     {
          TRexppA e;
          e.Compile(".*aabb.*");
          if (e.Match("xaaabbc"))
          {
              xxx = 2;
          }
     }
     {
          TRexppW e;
          e.Compile((const unsigned short *)L".*aabb.*");
          if (e.Match((const unsigned short *)L"xxxaaaabbcc"))
          {
              xxx = 1;
          }
     }
     {
          TRexppA e;
          e.Compile(".*aabb.*");
          if (e.Match("xxxaaaabbcc"))
          {
              xxx = 2;
          }
     }
}
void TRexp_noerror()
{
     int xxx = 0;
     {
          TRexppA e;
          e.Compile(".*aabb.*");
          if (e.Match("xxaabbc"))
          {
              xxx = 2;
          }
     }
     {
          TRexppA e;
          e.Compile(".*aabb.*");
          if (e.Match("xyaabbc"))
          {
              xxx = 2;
          }
     }
}
#endif
